install.packages('corpcor')
install.packages('mctest')
require(mgcv)
require(corpcor)
require(mctest)


#Importing datasets
all_sellerdata  = read.csv(file="C:\\Users\\f00456n\\Documents\\Amazon Price Dynamics\\Data Scraped\\New Data\\Modeling data sets\\Luggage\\finalnumsellers_modeldata1_luggage.csv", header=TRUE, sep=",")

modeldata = all_sellerdata[4:138,]

modeldata[is.na(modeldata)] = 0
attach(modeldata)
trainY = cbind(Y_amzn_olympia,Y_amzn_smsnite,Y_clust1_smsnite,Y_clust2_olympia,Y_clust2_rcklnd,Y_clust2_tc)

#AMAZON OLYMPIA

data_amzn_oly = data.frame(cbind(Y_amzn_olympia_lag1,Y_amzn_olympia_lag2,Y_amzn_olympia_lag3,   
                                   Y_amzn_smsnite_lag1,
                                   Y_clust1_smsnite_lag1,
                                   Y_amzn_smsnite_lag2,
                                   Y_clust2_olympia_lag3,
                                   Y_clust2_tc_lag1,
                                   meanseller_star_clust2_lag1,
                                   Y_clust1_smsnite_lag3,
                                   meanperct_sellerate_clust2_lag1,
                                   Y_clust2_tc_lag3,
                                   Y_clust2_tc_lag2,
                                   Y_clust1_smsnite_lag2,
                                   num_prime_clust2_lag1,
                                   Y_clust2_rcklnd_lag2,
                                   num_Freeship_clust2_lag1,
                                   Answered_Questionsolympia_lag1,
                                  # meanpricechange_extsite_lag1,
                                   Y_clust2_olympia_lag1,
                                   delsy_bottombrandlag1	,
                                   delsy_topbrandlag1	,
                                   oly_bottombrandlag1	,
                                   oly_topbrandlag1	,
                                   rcklnd_bottombrandlag1	,
                                   rcklnd_topbrandlag1	,
                                   smsnte_bottombrandlag1	,
                                   smsnte_topbrandlag1	,
                                   tc_bottombrandlag1	,
                                   tc_topbrandlag1	,
                                   incr20per_3p_oly	,
                                   incr20per_3p_rcklnd	,
                                   incr20per_3p_sam	,
                                   incr20per_3p_tc	,
                                   incr20per_amzn_oly	,
                                   incr20per_amzn_sam	,
                                   decr20per_3p_oly	,
                                   decr20per_3p_rcklnd	,
                                   decr20per_3p_tc	,
                                   decr20per_amzn_sam	,
                                   decr20per_3p_sam	,
                                   decr20per_amzn_oly	,
                                   decr10per_3p_oly	,
                                   decr10per_3p_rcklnd	,
                                   decr10per_3p_sam	,
                                   decr10per_3p_tc	,
                                   decr10per_amzn_oly	,
                                   decr10per_amzn_sam	,
                                   decr5per_3p_oly	,
                                   decr5per_3p_rcklnd	,
                                   decr5per_3p_sam	,
                                   decr5per_3p_tc	,
                                   decr5per_amzn_oly	,
                                   decr5per_amzn_sam	,
                                   incr10per_3p_oly	,
                                   incr10per_3p_rcklnd	,
                                   incr10per_3p_sam	,
                                   incr10per_3p_tc	,
                                   incr10per_amzn_oly	,
                                   incr10per_amzn_sam	,
                                   incr5per_3p_oly	,
                                   incr5per_3p_rcklnd	,
                                   incr5per_3p_sam	,
                                   incr5per_3p_tc	,
                                   incr5per_amzn_oly	,
                                   incr5per_amzn_sam	,
                                   weekend,
                                   #additional covariates on reviews
                                   maxProduct_reviews_delsy_lag1,
                                   Product_reviews_kcole_lag1,
                                   Product_reviews_olympia_lag1,
                                   Product_reviews_rcklnd_lag1,
                                   Product_reviews_smsnite_lag1,
                                   Product_reviews_tc_lag1,
                                   meanprodstar_rate_delsy_lag1,
                                   prodstar_kcole_lag1,
                                   prodstar_olympia_lag1,
                                   prodstar_rcklnd_lag1,        
                                   prodstar_smsnite_lag1,
                                   prodstar_tc_lag1,
                                   #additional variables from RnR Round 2
                                   mean_starrateOLY_3p_lag,
                                   mean_primeOLY_3p_lag,
                                   seasonal_sale,
                                   buyboxprice_olympia_lag1,
                                   ###broken down external site price changes with lags
                                   maxpricechange_sears,
                                   maxpricechange_searslag1,
                                   maxpricechange_searslag2,
                                   maxpricechange_searslag3,
                                   maxpricechange_wm,
                                   maxpricechange_wmlag1,
                                   maxpricechange_wmlag2,
                                   maxpricechange_wmlag3))


#INCLUDING ADDITIONAL FE AND IE POST JM RnR
#test = gam(Y_amzn_olympia ~ num_prime_clust2_lag1 + meanperct_sellerate_clust2_lag1,family= gaussian(link ='identity') ,data=data_amzn_oly,method="REML",optimizer=c("outer","newton"), fit = TRUE) 

gam13_amzn_oly = gam(Y_amzn_olympia ~  Y_amzn_olympia_lag2 + 
                         #Y_clust2_tc_lag1+
                        # meanperct_sellerate_clust2_lag1+
                       #  num_prime_clust2_lag1 +
                         #Y_amzn_smsnite_lag2+
                         #s(Y_clust2_olympia_lag3) +
                      #   delsy_bottombrandlag1	+
                         #delsy_topbrandlag1	+
                         #oly_bottombrandlag1	+
                         #oly_topbrandlag1	+
                         #rcklnd_bottombrandlag1	+
                        # rcklnd_topbrandlag1	+
                        # smsnte_bottombrandlag1	+
                        # smsnte_topbrandlag1	+
                         #tc_bottombrandlag1	+
                        # tc_topbrandlag1	+
                        # incr20per_3p_oly	+
                         #incr20per_3p_rcklnd	+
                         #incr20per_3p_sam	+
                         incr20per_3p_tc	+
                         #incr20per_amzn_oly	+
                         #incr20per_amzn_sam	+
                         #decr20per_3p_oly	+
                         #decr20per_3p_rcklnd	+
                         #decr20per_3p_tc	+
                         #decr20per_amzn_sam	+
                         #decr20per_3p_sam	+
                         decr20per_amzn_oly	+
                         #  decr10per_3p_oly	+
                        # decr10per_3p_rcklnd	+
                         #decr10per_3p_sam	+
                         #decr10per_3p_tc	+
                         #decr10per_amzn_oly	+
                         # decr10per_amzn_sam	+
                        # decr5per_3p_oly	+
                        # decr5per_3p_rcklnd	+
                          #decr5per_3p_sam	+
                         #decr5per_3p_tc	+
                       #  decr5per_amzn_oly	+
                     #    decr5per_amzn_sam	+
                         incr10per_3p_oly	+
                       #  incr10per_3p_rcklnd	+
                       #   incr10per_3p_sam	+
                          #incr10per_3p_tc	+
                       #  incr10per_amzn_oly	+
                        # incr10per_amzn_sam	+
                        #  incr5per_3p_oly	+
                       #  incr5per_3p_rcklnd	+
                        #  incr5per_3p_sam	+
                        # incr5per_3p_tc	+
                       # incr5per_amzn_oly	+
                         #incr5per_amzn_sam	+
                       #  Answered_Questionsolympia_lag1+
                      #   mean_starrateOLY_3p_lag +
                         weekend+
                         #rcklnd_topbrandlag1*incr5per_3p_rcklnd
                       #additional covariates on reviews
                      # maxProduct_reviews_delsy_lag1+
                      # Product_reviews_kcole_lag1 +
                        Product_reviews_olympia_lag1 +
                       #Product_reviews_rcklnd_lag1+
                      # Product_reviews_smsnite_lag1+
                      # Product_reviews_tc_lag1+
                      # meanprodstar_rate_delsy_lag1+
                      # prodstar_kcole_lag1+
                       prodstar_olympia_lag1+
                     #  prodstar_rcklnd_lag1+   
                       buyboxprice_olympia_lag1+
                     #  prodstar_smsnite_lag1+
                      # prodstar_tc_lag1+
                       #additional variables from RnR Round 2
                         seasonal_sale+
                       
                       ###4th round additions
                      # maxpricechange_sears +
                     #  maxpricechange_searslag1 +
                      # maxpricechange_searslag2 +
                      # maxpricechange_searslag3 +
                      # maxpricechange_wm  +
                       maxpricechange_wmlag1 
                      # maxpricechange_wmlag2 +
                       #maxpricechange_wmlag3
                       ,family= gaussian(link ='identity') ,data=data_amzn_oly,method="REML",optimizer=c("outer","newton"), fit = TRUE)

summary(gam13_amzn_oly)

#AMAZON tc

data_amzn_tc = data.frame(cbind(Y_amzn_tc_lag1,Y_amzn_tc_lag2,Y_amzn_tc_lag3,   
                                Y_amzn_smsnite_lag1,
                                Y_clust1_smsnite_lag1,
                                Y_amzn_smsnite_lag2,
                                Y_clust2_tc_lag3,
                                Y_clust2_tc_lag1,
                                meanseller_star_clust2_lag1,
                                Y_clust1_smsnite_lag3,
                                meanperct_sellerate_clust2_lag1,
                                Y_clust1_smsnite_lag2,
                                num_prime_clust2_lag1,
                                Y_clust2_rcklnd_lag2,
                                num_Freeship_clust2_lag1,
                                Answered_Questionstc_lag1,
                                # meanpricechange_extsite_lag1,
                                delsy_bottombrandlag1	,
                                delsy_topbrandlag1	,
                                tc_bottombrandlag1	,
                                tc_topbrandlag1	,
                                rcklnd_bottombrandlag1	,
                                rcklnd_topbrandlag1	,
                                smsnte_bottombrandlag1	,
                                smsnte_topbrandlag1	,
                                tc_bottombrandlag1	,
                                tc_topbrandlag1	,
                                incr20per_3p_tc	,
                                incr20per_3p_rcklnd	,
                                incr20per_3p_sam	,
                                incr20per_3p_tc	,
                                incr20per_amzn_tc	,
                                incr20per_amzn_sam	,
                                decr20per_3p_tc	,
                                decr20per_3p_rcklnd	,
                                decr20per_3p_tc	,
                                decr20per_amzn_sam	,
                                decr20per_3p_sam	,
                                decr20per_amzn_tc	,
                                decr10per_3p_tc	,
                                decr10per_3p_rcklnd	,
                                decr10per_3p_sam	,
                                decr10per_3p_tc	,
                                decr10per_amzn_tc	,
                                decr10per_amzn_sam	,
                                decr5per_3p_tc	,
                                decr5per_3p_rcklnd	,
                                decr5per_3p_sam	,
                                decr5per_3p_tc	,
                                decr5per_amzn_tc	,
                                decr5per_amzn_sam	,
                                incr10per_3p_tc	,
                                incr10per_3p_rcklnd	,
                                incr10per_3p_sam	,
                                incr10per_3p_tc	,
                                incr10per_amzn_tc	,
                                incr10per_amzn_sam	,
                                incr5per_3p_tc	,
                                incr5per_3p_rcklnd	,
                                incr5per_3p_sam	,
                                incr5per_3p_tc	,
                                incr5per_amzn_tc	,
                                incr5per_amzn_sam	,
                                weekend,
                                #additional covariates on reviews
                                maxProduct_reviews_delsy_lag1,
                                Product_reviews_kcole_lag1,
                                Product_reviews_tc_lag1,
                                Product_reviews_rcklnd_lag1,
                                Product_reviews_smsnite_lag1,
                                Product_reviews_tc_lag1,
                                meanprodstar_rate_delsy_lag1,
                                prodstar_kcole_lag1,
                                prodstar_tc_lag1,
                                prodstar_rcklnd_lag1,        
                                prodstar_smsnite_lag1,
                                prodstar_tc_lag1,
                                #additional variables from RnR Round 2
                                mean_starrateTC_3p_lag,
                                mean_primeTC_3p_lag,
                                seasonal_sale,
                                buyboxprice_tc_lag1,
                                ###broken down external site price changes with lags
                                maxpricechange_sears,
                                maxpricechange_searslag1,
                                maxpricechange_searslag2,
                                maxpricechange_searslag3,
                                maxpricechange_wm,
                                maxpricechange_wmlag1,
                                maxpricechange_wmlag2,
                                maxpricechange_wmlag3))


#INCLUDING ADDITIONAL FE AND IE POST JM RnR
#test = gam(Y_amzn_tc ~ num_prime_clust2_lag1 + meanperct_sellerate_clust2_lag1,family= gaussian(link ='identity') ,data=data_amzn_tc,method="REML",optimizer=c("outer","newton"), fit = TRUE) 

gam13_amzn_tc = gam(Y_amzn_tc ~  
                      #Y_amzn_tc_lag2 + 
                      #Y_clust2_tc_lag1+
                      # meanperct_sellerate_clust2_lag1+
                      #  num_prime_clust2_lag1 +
                      #Y_amzn_smsnite_lag2+
                      #s(Y_clust2_tc_lag3) +
                      #   delsy_bottombrandlag1	+
                      #delsy_topbrandlag1	+
                      #tc_bottombrandlag1	+
                      #tc_topbrandlag1	+
                      #rcklnd_bottombrandlag1	+
                      # rcklnd_topbrandlag1	+
                      # smsnte_bottombrandlag1	+
                      # smsnte_topbrandlag1	+
                      #tc_bottombrandlag1	+
                      # tc_topbrandlag1	+
                      # incr20per_3p_tc	+
                      #incr20per_3p_rcklnd	+
                      #incr20per_3p_sam	+
                      incr20per_3p_tc	+
                      #incr20per_amzn_tc	+
                      #incr20per_amzn_sam	+
                      #decr20per_3p_tc	+
                      #decr20per_3p_rcklnd	+
                      #decr20per_3p_tc	+
                      #decr20per_amzn_sam	+
                      #decr20per_3p_sam	+
                      decr20per_amzn_tc	+
                      #  decr10per_3p_tc	+
                      # decr10per_3p_rcklnd	+
                      #decr10per_3p_sam	+
                      #decr10per_3p_tc	+
                      #decr10per_amzn_tc	+
                      # decr10per_amzn_sam	+
                      # decr5per_3p_tc	+
                      # decr5per_3p_rcklnd	+
                      #decr5per_3p_sam	+
                      #decr5per_3p_tc	+
                      #  decr5per_amzn_tc	+
                      #    decr5per_amzn_sam	+
                    #  incr10per_3p_tc	+
                      #  incr10per_3p_rcklnd	+
                      #   incr10per_3p_sam	+
                      #incr10per_3p_tc	+
                      #  incr10per_amzn_tc	+
                      # incr10per_amzn_sam	+
                      #  incr5per_3p_tc	+
                      #  incr5per_3p_rcklnd	+
                      #  incr5per_3p_sam	+
                      # incr5per_3p_tc	+
                      # incr5per_amzn_tc	+
                      #incr5per_amzn_sam	+
                      #  Answered_Questionstc_lag1+
                      #   mean_starratetc_3p_lag +
                      weekend+
                      #rcklnd_topbrandlag1*incr5per_3p_rcklnd
                      #additional covariates on reviews
                      # maxProduct_reviews_delsy_lag1+
                      # Product_reviews_kcole_lag1 +
                      Product_reviews_tc_lag1 +
                      #Product_reviews_rcklnd_lag1+
                      # Product_reviews_smsnite_lag1+
                      # Product_reviews_tc_lag1+
                      # meanprodstar_rate_delsy_lag1+
                      # prodstar_kcole_lag1+
                      prodstar_tc_lag1+
                      #  prodstar_rcklnd_lag1+   
                      buyboxprice_tc_lag1+
                      #  prodstar_smsnite_lag1+
                      # prodstar_tc_lag1+
                      #additional variables from RnR Round 2
                      seasonal_sale+
                      
                      ###4th round additions
                      # maxpricechange_sears +
                      #  maxpricechange_searslag1 +
                      # maxpricechange_searslag2 +
                      # maxpricechange_searslag3 +
                      # maxpricechange_wm  +
                      #maxpricechange_wmlag1 
                     maxpricechange_wmlag2 
                    #maxpricechange_wmlag3
                    ,family= gaussian(link ='identity') ,data=data_amzn_tc,method="REML",optimizer=c("outer","newton"), fit = TRUE)

summary(gam13_amzn_tc)
#AMAZON Samsonite

data_amzn_smsnite = data.frame(cbind(Y_amzn_smsnite_lag1,Y_amzn_smsnite_lag2,Y_amzn_smsnite_lag3,Y_amzn_olympia_lag1,Y_amzn_olympia_lag2,Y_amzn_olympia_lag3,   
                                     Y_clust1_smsnite_lag1,
                                     Y_clust2_olympia_lag3,
                                     Y_clust2_tc_lag1,
                                     buyboxprice_smsnite_lag1,
                                     meanseller_star_clust2_lag1,
                                     Y_clust1_smsnite_lag3,
                                     meanperct_sellerate_clust2_lag1,
                                     Y_clust2_tc_lag3,
                                     Y_clust2_tc_lag2,
                                     Y_clust1_smsnite_lag2,
                                     num_prime_clust2_lag1,
                                     Y_clust2_rcklnd_lag2,
                                     num_Freeship_clust2_lag1,
                                     Answered_Questionsolympia_lag1,
                                     Y_clust2_olympia_lag1,
                                     delsy_bottombrandlag1	,
                                     delsy_topbrandlag1	,
                                     oly_bottombrandlag1	,
                                     oly_topbrandlag1	,
                                     rcklnd_bottombrandlag1	,
                                     rcklnd_topbrandlag1	,
                                     smsnte_bottombrandlag1	,
                                     smsnte_topbrandlag1	,
                                     tc_bottombrandlag1	,
                                     tc_topbrandlag1	,
                                     incr20per_3p_oly	,
                                     incr20per_3p_rcklnd	,
                                     incr20per_3p_sam	,
                                     incr20per_3p_tc	,
                                     incr20per_amzn_oly	,
                                     incr20per_amzn_sam	,
                                     decr20per_3p_oly	,
                                     decr20per_3p_rcklnd	,
                                     decr20per_3p_tc	,
                                     decr20per_amzn_sam	,
                                     decr20per_3p_sam	,
                                     decr20per_amzn_oly	,
                                     decr10per_3p_oly	,
                                     decr10per_3p_rcklnd	,
                                     decr10per_3p_sam	,
                                     decr10per_3p_tc	,
                                     decr10per_amzn_oly	,
                                     decr10per_amzn_sam	,
                                     decr5per_3p_oly	,
                                     decr5per_3p_rcklnd	,
                                     decr5per_3p_sam	,
                                     decr5per_3p_tc	,
                                     decr5per_amzn_oly	,
                                     decr5per_amzn_sam	,
                                     incr10per_3p_oly	,
                                     incr10per_3p_rcklnd	,
                                     incr10per_3p_sam	,
                                     incr10per_3p_tc	,
                                     incr10per_amzn_oly	,
                                     incr10per_amzn_sam	,
                                     incr5per_3p_oly	,
                                     incr5per_3p_rcklnd	,
                                     incr5per_3p_sam	,
                                     incr5per_3p_tc	,
                                     incr5per_amzn_oly	,
                                     incr5per_amzn_sam	,
                                     weekend,
                                     #additional covariates on reviews
                                     maxProduct_reviews_delsy_lag1,
                                     Product_reviews_kcole_lag1,
                                     Product_reviews_olympia_lag1,
                                     Product_reviews_rcklnd_lag1,
                                     Product_reviews_smsnite_lag1,
                                     Product_reviews_tc_lag1,
                                     meanprodstar_rate_delsy_lag1,
                                     prodstar_kcole_lag1,
                                     prodstar_olympia_lag1,
                                     prodstar_rcklnd_lag1,        
                                     prodstar_smsnite_lag1,
                                     prodstar_tc_lag1,
                                     #additional variables from RnR Round 2
                                     mean_starrateSAM_3p_lag,
                                     mean_primeSAM_3p_lag,
                                     seasonal_sale,
                                     ###broken down external site price changes with lags
                                     maxpricechange_sears,
                                     maxpricechange_searslag1,
                                     maxpricechange_searslag2,
                                     maxpricechange_searslag3,
                                     maxpricechange_wm,
                                     maxpricechange_wmlag1,
                                     maxpricechange_wmlag2,
                                     maxpricechange_wmlag3))

#FIXED AND INTERACTION EFFECTS FOR JM RNR

gam13_amzn_smsnite = gam(Y_amzn_smsnite ~ 
                          # Y_amzn_smsnite_lag1+
                          # Y_clust1_smsnite_lag1+
                           # Y_clust2_olympia_lag1+
                           buyboxprice_smsnite_lag1 +
                         #  delsy_bottombrandlag1	+
                           #delsy_topbrandlag1	+
                          # oly_bottombrandlag1	+
                           #oly_topbrandlag1	+
                            #rcklnd_topbrandlag1	+
                           # smsnte_bottombrandlag1	+
                           # smsnte_topbrandlag1	+
                           #tc_bottombrandlag1	+
                           # tc_topbrandlag1	+
                           # incr20per_3p_oly	+
                           #incr20per_3p_rcklnd	+
                           #incr20per_3p_sam	+
                           #incr20per_3p_tc	+
                           #incr20per_amzn_oly	+
                           #incr20per_amzn_sam	+
                           #decr20per_3p_oly	+
                           #decr20per_3p_rcklnd	+
                           #decr20per_3p_tc	+
                          # decr20per_amzn_sam	+
                          # decr20per_3p_sam	+
                           #decr20per_amzn_oly	+
                           #  decr10per_3p_oly	+
                           # decr10per_3p_rcklnd	+
                             decr10per_3p_sam	+
                           #decr10per_3p_tc	+
                           # decr10per_amzn_oly	+
                           # decr10per_amzn_sam	+
                           #decr5per_3p_oly	+
                         # decr5per_3p_rcklnd	+
                        # decr5per_3p_sam	+
                           #decr5per_3p_tc	+
                           #decr5per_amzn_oly	+
                           decr5per_amzn_sam	+
                           #incr10per_3p_oly	+
                           #  incr10per_3p_rcklnd	+
                          # incr10per_3p_sam	+
                          # incr10per_3p_tc	+
                           # incr10per_amzn_oly	+
                           # incr10per_amzn_sam	+
                          # incr5per_3p_oly	+
                           #  incr5per_3p_rcklnd	+
                          #  incr5per_3p_sam	+
                           # incr5per_3p_tc	+
                           # incr5per_amzn_oly	+
                           #incr5per_amzn_sam	+
                          # Answered_Questionsolympia_lag1+
                           #additional covariates on reviews
                          # maxProduct_reviews_delsy_lag1+
                          # Product_reviews_kcole_lag1 +
                          # Product_reviews_olympia_lag1 +
                         #  Product_reviews_rcklnd_lag1+
                           Product_reviews_smsnite_lag1+
                         #  Product_reviews_tc_lag1+
                        #   meanprodstar_rate_delsy_lag1+
                          # prodstar_kcole_lag1+
                        #   prodstar_olympia_lag1+
                        #   prodstar_rcklnd_lag1+        
                           prodstar_smsnite_lag1+
                         #  prodstar_tc_lag1+
                            mean_starrateSAM_3p_lag + 
                           weekend+
                           seasonal_sale+
                          ###4th round additions
                           # maxpricechange_sears +
                           #maxpricechange_searslag1 +
                           maxpricechange_searslag2 +
                          # maxpricechange_searslag3 +
                          # maxpricechange_wm  +
                           maxpricechange_wmlag1 
                          #maxpricechange_wmlag2 +
                         #maxpricechange_wmlag3
                         ,family= gaussian(link ='identity') ,data=data_amzn_smsnite ,method="REML",optimizer=c("outer","newton"), fit = TRUE)


summary(gam13_amzn_smsnite)


#CLUSTER 1
#trainY = cbind(Y_amzn_olympia,Y_amzn_smsnite,Y_clust1_smsnite,Y_clust2_olympia,Y_clust2_rcklnd,Y_clust2_tc)

data_clust1 = data.frame(cbind(Y_clust1_smsnite_lag1,Y_clust1_smsnite_lag2,Y_clust1_smsnite_lag3,
                               Y_amzn_smsnite_lag1,
                               Y_amzn_olympia_lag1,
                               Y_amzn_smsnite_lag2,
                               Y_amzn_olympia_lag3,
                               buyboxprice_smsnite_lag1,
                               Y_clust2_olympia_lag3,
                               Y_clust2_tc_lag1,
                               meanseller_star_clust2_lag1,
                               Y_amzn_olympia_lag2,
                               meanperct_sellerate_clust2_lag1,
                               Y_clust2_tc_lag3,
                               Y_clust2_tc_lag2,
                               num_prime_clust2_lag1,
                               Y_clust2_rcklnd_lag2,
                               num_Freeship_clust2_lag1,
                               Answered_Questionsolympia_lag1,
                               Y_clust2_olympia_lag1,
                               delsy_bottombrandlag1	,
                               delsy_topbrandlag1	,
                               oly_bottombrandlag1	,
                               oly_topbrandlag1	,
                               rcklnd_bottombrandlag1	,
                               rcklnd_topbrandlag1	,
                               smsnte_bottombrandlag1	,
                               smsnte_topbrandlag1	,
                               tc_bottombrandlag1	,
                               tc_topbrandlag1	,
                               incr20per_3p_oly	,
                               incr20per_3p_rcklnd	,
                               incr20per_3p_sam	,
                               incr20per_3p_tc	,
                               incr20per_amzn_oly	,
                               incr20per_amzn_sam	,
                               decr20per_3p_oly	,
                               decr20per_3p_rcklnd	,
                               decr20per_3p_tc	,
                               decr20per_amzn_sam	,
                               decr20per_3p_sam	,
                               decr20per_amzn_oly	,
                               decr10per_3p_oly	,
                               decr10per_3p_rcklnd	,
                               decr10per_3p_sam	,
                               decr10per_3p_tc	,
                               decr10per_amzn_oly	,
                               decr10per_amzn_sam	,
                               decr5per_3p_oly	,
                               decr5per_3p_rcklnd	,
                               decr5per_3p_sam	,
                               decr5per_3p_tc	,
                               decr5per_amzn_oly	,
                               decr5per_amzn_sam	,
                               incr10per_3p_oly	,
                               incr10per_3p_rcklnd	,
                               incr10per_3p_sam	,
                               incr10per_3p_tc	,
                               incr10per_amzn_oly	,
                               incr10per_amzn_sam	,
                               incr5per_3p_oly	,
                               incr5per_3p_rcklnd	,
                               incr5per_3p_sam	,
                               incr5per_3p_tc	,
                               incr5per_amzn_oly	,
                               incr5per_amzn_sam	,
                               weekend,
                               #additional covariates on reviews
                               maxProduct_reviews_delsy_lag1,
                               Product_reviews_kcole_lag1,
                               Product_reviews_olympia_lag1,
                               Product_reviews_rcklnd_lag1,
                               Product_reviews_smsnite_lag1,
                               Product_reviews_tc_lag1,
                               meanprodstar_rate_delsy_lag1,
                               prodstar_kcole_lag1,
                               prodstar_olympia_lag1,
                               prodstar_rcklnd_lag1,        
                               prodstar_smsnite_lag1,
                               prodstar_tc_lag1,
                               #additional variables from RnR Round 2
                               mean_starrateSAM_3p_lag,
                               mean_primeSAM_3p_lag,
                               seasonal_sale,
                               ###broken down external site price changes with lags
                               maxpricechange_sears,
                               maxpricechange_searslag1,
                               maxpricechange_searslag2,
                               maxpricechange_searslag3,
                               maxpricechange_wm,
                               maxpricechange_wmlag1,
                               maxpricechange_wmlag2,
                               maxpricechange_wmlag3))

#FIXED AND INTERACTION EFFECTS INCLUDED FOR JM RNR

gam9_clust1 = gam(Y_clust1_smsnite ~  
                   # Y_clust1_smsnite_lag1+
                  #  Y_clust2_tc_lag1+
                   # Y_clust1_smsnite_lag2+
                    #Y_clust1_smsnite_lag3+
                    #Y_clust2_rcklnd_lag2+
                    buyboxprice_smsnite_lag1 + 
                   # num_prime_clust2_lag1+
                   # num_Freeship_clust2_lag1+
                    Answered_Questionsolympia_lag1+
                     #Y_clust2_olympia_lag1+
                   # delsy_bottombrandlag1	+
                    #delsy_topbrandlag1	+
                    # oly_bottombrandlag1	+
                    #oly_topbrandlag1	+
                     # smsnte_bottombrandlag1	+
                    # smsnte_topbrandlag1	+
                    #tc_bottombrandlag1	+
                    # tc_topbrandlag1	+
                    # incr20per_3p_oly	+
                    #incr20per_3p_rcklnd	+
                    incr20per_3p_sam	+
                    ##incr20per_3p_tc	+
                    #incr20per_amzn_oly	+
                    incr20per_amzn_sam	+
                    #decr20per_3p_oly	+
                    #decr20per_3p_rcklnd	+
                    ##decr20per_3p_tc	+
                    decr20per_amzn_sam	+
                    ##decr20per_3p_sam	+
                    decr20per_amzn_oly	+
                    #  decr10per_3p_oly	+
                    # decr10per_3p_rcklnd	+
                    # decr10per_3p_sam	+
                    #decr10per_3p_tc	+
                    # decr10per_amzn_oly	+
                     decr10per_amzn_sam	+
                    decr5per_3p_oly	+
                    # decr5per_3p_rcklnd	+
                    #decr5per_3p_sam	+
                    #decr5per_3p_tc	+
                    #decr5per_amzn_oly	+
                   # decr5per_amzn_sam	+
                    #incr10per_3p_oly	+
                    #  incr10per_3p_rcklnd	+
                    incr10per_3p_sam	+
                    #incr10per_3p_tc	+
                    #additional covariates on reviews
                    maxProduct_reviews_delsy_lag1+
                    #Product_reviews_kcole_lag1 +
                    #Product_reviews_olympia_lag1 +
                    Product_reviews_rcklnd_lag1+
                    Product_reviews_smsnite_lag1+
                    Product_reviews_tc_lag1+
                   # meanprodstar_rate_delsy_lag1+
                   # prodstar_kcole_lag1+
                   # prodstar_olympia_lag1+
                   # prodstar_rcklnd_lag1+        
                    prodstar_smsnite_lag1+
                    prodstar_tc_lag1+
                    #decr5per_3p_oly*meanpricechange_extsite_lag1+
                    weekend +
                    # incr10per_amzn_oly	+
                    # incr10per_amzn_sam	+
                    # incr5per_3p_oly	+
                    #  incr5per_3p_rcklnd	+
                    # incr5per_3p_sam	+
                    # incr5per_3p_tc	
                    # incr5per_amzn_oly	+
                    #incr5per_amzn_sam	+
                    #additional variables from RnR Round 2
                  #mean_starrateSAM_clust1_lag1+
                  #mean_starrateSAM_clust2_lag1+
                  #mean_primeSAM_clust1_lag1+
                  #mean_primeSAM_clust2_lag1+
                  seasonal_sale+
                    ###4th round additions
                  #  maxpricechange_sears +
                    maxpricechange_searslag1 +
                    maxpricechange_searslag2 +
                    #maxpricechange_searslag3 +
                  #  maxpricechange_wm  +
                    #maxpricechange_wmlag1 +
                    maxpricechange_wmlag2 
                   # maxpricechange_wmlag3
                    ,family= gaussian(link ='identity') ,data=data_clust1,method="REML",optimizer=c("outer","newton"), fit = TRUE)


summary(gam9_clust1)


#CLUSTER 2:OLYMPIA

data_clust2_olympia = data.frame(cbind(Y_clust2_olympia_lag1,Y_clust2_olympia_lag2,Y_clust2_olympia_lag3,
                                       Y_amzn_smsnite_lag1,
                                       Y_clust1_smsnite_lag1,
                                       buyboxprice_olympia_lag1,
                                       Y_amzn_olympia_lag1,
                                       Y_amzn_smsnite_lag2,
                                       Y_amzn_olympia_lag3,
                                       Y_clust2_tc_lag1,
                                       meanseller_star_clust2_lag1,
                                       Y_clust1_smsnite_lag3,
                                       Y_amzn_olympia_lag2,
                                       meanperct_sellerate_clust2_lag1,
                                       Y_clust2_tc_lag3,
                                       Y_clust2_tc_lag2,
                                       Y_clust1_smsnite_lag2,
                                       num_prime_clust2_lag1,
                                       Y_clust2_rcklnd_lag2,
                                       num_Freeship_clust2_lag1,
                                       Answered_Questionsolympia_lag1,
                                       delsy_bottombrandlag1	,
                                       delsy_topbrandlag1	,
                                       oly_bottombrandlag1	,
                                       oly_topbrandlag1	,
                                       rcklnd_bottombrandlag1	,
                                       rcklnd_topbrandlag1	,
                                       smsnte_bottombrandlag1	,
                                       smsnte_topbrandlag1	,
                                       tc_bottombrandlag1	,
                                       tc_topbrandlag1	,
                                       incr20per_3p_oly	,
                                       incr20per_3p_rcklnd	,
                                       incr20per_3p_sam	,
                                       incr20per_3p_tc	,
                                       incr20per_amzn_oly	,
                                       incr20per_amzn_sam	,
                                       decr20per_3p_oly	,
                                       decr20per_3p_rcklnd	,
                                       decr20per_3p_tc	,
                                       decr20per_amzn_sam	,
                                       decr20per_3p_sam	,
                                       decr20per_amzn_oly	,
                                       decr10per_3p_oly	,
                                       decr10per_3p_rcklnd	,
                                       decr10per_3p_sam	,
                                       decr10per_3p_tc	,
                                       decr10per_amzn_oly	,
                                       decr10per_amzn_sam	,
                                       decr5per_3p_oly	,
                                       decr5per_3p_rcklnd	,
                                       decr5per_3p_sam	,
                                       decr5per_3p_tc	,
                                       decr5per_amzn_oly	,
                                       decr5per_amzn_sam	,
                                       incr10per_3p_oly	,
                                       incr10per_3p_rcklnd	,
                                       incr10per_3p_sam	,
                                       incr10per_3p_tc	,
                                       incr10per_amzn_oly	,
                                       incr10per_amzn_sam	,
                                       incr5per_3p_oly	,
                                       incr5per_3p_rcklnd	,
                                       incr5per_3p_sam	,
                                       incr5per_3p_tc	,
                                       incr5per_amzn_oly	,
                                       incr5per_amzn_sam	,
                                       weekend,
                                       #additional covariates on reviews
                                       maxProduct_reviews_delsy_lag1,
                                       Product_reviews_kcole_lag1,
                                       Product_reviews_olympia_lag1,
                                       Product_reviews_rcklnd_lag1,
                                       Product_reviews_smsnite_lag1,
                                       Product_reviews_tc_lag1,
                                       meanprodstar_rate_delsy_lag1,
                                       prodstar_kcole_lag1,
                                       prodstar_olympia_lag1,
                                       prodstar_rcklnd_lag1,        
                                       prodstar_smsnite_lag1,
                                       prodstar_tc_lag1,
                                       #additional variables from RnR Round 2
                                       mean_starrateSAM_3p_lag,
                                       mean_primeSAM_3p_lag,
                                       seasonal_sale,
                                       ###broken down external site price changes with lags
                                       maxpricechange_sears,
                                       maxpricechange_searslag1,
                                       maxpricechange_searslag2,
                                       maxpricechange_searslag3,
                                       maxpricechange_wm,
                                       maxpricechange_wmlag1,
                                       maxpricechange_wmlag2,
                                       maxpricechange_wmlag3))


#FIXED AND INTERACTION EFFECTS JM RNR
gam9_clust2_olympia = gam(Y_clust2_olympia ~ 
                            #Y_clust2_olympia_lag3	+
                            #Y_clust2_tc_lag1+
                            #Y_amzn_smsnite_lag2+
                            buyboxprice_olympia_lag1 + 
                            #num_Freeship_clust2_lag1+
                            meanperct_sellerate_clust2_lag1+
                           # s(meanpricechange_extsite_lag1)+
                           # delsy_bottombrandlag1	+
                            #delsy_topbrandlag1	+
                           # oly_bottombrandlag1	+
                           # oly_topbrandlag1	+
                            incr20per_3p_oly	+
                            #incr20per_3p_rcklnd	+
                            #incr20per_3p_sam	+
                            #incr20per_3p_tc	+
                            #incr20per_amzn_oly	+
                           # incr20per_amzn_sam	+
                            #decr20per_3p_oly	+
                            #decr20per_3p_rcklnd	+
                            #decr20per_3p_tc	+
                           # decr20per_amzn_sam	+
                           # decr20per_3p_sam	+
                            #decr20per_amzn_oly	+
                            #  decr10per_3p_oly	+
                            # decr10per_3p_rcklnd	+
                            # decr10per_3p_sam	+
                            #  decr10per_3p_tc	+
                            # decr10per_amzn_oly	+
                            # decr10per_amzn_sam	+
                            #decr5per_3p_oly	+
                            #decr5per_3p_rcklnd	+
                           # decr5per_3p_sam	+
                           # decr5per_3p_tc	+
                           # decr5per_amzn_oly	+
                            # decr5per_amzn_sam	+
                            incr10per_3p_oly	+
                            #  incr10per_3p_rcklnd	+
                           # incr10per_3p_sam	+
                            incr10per_3p_tc	+
                            #additional covariates on reviews
                            mean_starrateSAM_3p_lag + 
                           # mean_primeSAM_3p_lag +
                           # maxProduct_reviews_delsy_lag1 +
                            Product_reviews_kcole_lag1 +
                           # Product_reviews_olympia_lag1 +
                            Product_reviews_rcklnd_lag1+
                            #Product_reviews_smsnite_lag1+
                            #Product_reviews_tc_lag1+
                            meanprodstar_rate_delsy_lag1+
                            prodstar_kcole_lag1+
                           # prodstar_olympia_lag1+
                           # prodstar_rcklnd_lag1+        
                           # prodstar_smsnite_lag1+
                           # prodstar_tc_lag1+
                            weekend +
                          # incr10per_amzn_oly	+
                          # incr10per_amzn_sam	+
                          # incr5per_3p_oly	+
                          #  incr5per_3p_rcklnd	+
                          # incr5per_3p_sam	+
                          # incr5per_3p_tc	
                          # incr5per_amzn_oly	+
                          #incr5per_amzn_sam	+
                            #additional variables from RnR Round 2
                            #mean_starrateSAM_clust1_lag1+
                            #mean_starrateSAM_clust2_lag1+
                          #mean_primeSAM_clust1_lag1+
                          #mean_primeSAM_clust2_lag1+
                          seasonal_sale+
                            ###4th round additions
                            #  maxpricechange_sears +
                           # maxpricechange_searslag1 +
                          #  maxpricechange_searslag2 +
                           # maxpricechange_searslag3 +
                            #  maxpricechange_wm  +
                           # maxpricechange_wmlag1 +
                            maxpricechange_wmlag2 
                            #maxpricechange_wmlag3
                          ,family= gaussian(link ='identity') ,data=data_clust2_olympia,method="REML",optimizer=c("outer","newton"), fit = TRUE)

summary(gam9_clust2_olympia)


#CLUSTER 2: Rockland

data_clust2_rcklnd = data.frame(cbind(Y_clust2_rcklnd_lag1,
                                      Y_clust2_rcklnd_lag2,
                                      Y_clust2_rcklnd_lag3,
                                      Y_amzn_smsnite_lag1,
                                      Y_clust1_smsnite_lag1,
                                      Y_amzn_olympia_lag1,
                                      Y_amzn_smsnite_lag2,
                                      Y_amzn_olympia_lag3,
                                      Y_clust2_olympia_lag3,
                                      Y_clust2_tc_lag1,
                                      meanseller_star_clust2_lag1,
                                      buyboxprice_rcklnd_lag1,
                                      Y_clust1_smsnite_lag3,
                                      Y_amzn_olympia_lag2,
                                      meanperct_sellerate_clust2_lag1,
                                      Y_clust2_tc_lag3,
                                      Y_clust2_tc_lag2,
                                      Y_clust1_smsnite_lag2,
                                      num_prime_clust2_lag1,
                                      num_Freeship_clust2_lag1,
                                      Answered_Questionsolympia_lag1,
                                      Y_clust2_olympia_lag1,
                                      delsy_bottombrandlag1	,
                                      delsy_topbrandlag1	,
                                      oly_bottombrandlag1	,
                                      oly_topbrandlag1	,
                                      rcklnd_bottombrandlag1	,
                                      rcklnd_topbrandlag1	,
                                      smsnte_bottombrandlag1	,
                                      smsnte_topbrandlag1	,
                                      tc_bottombrandlag1	,
                                      tc_topbrandlag1	,
                                      incr20per_3p_oly	,
                                      incr20per_3p_rcklnd	,
                                      incr20per_3p_sam	,
                                      incr20per_3p_tc	,
                                      incr20per_amzn_oly	,
                                      incr20per_amzn_sam	,
                                      decr20per_3p_oly	,
                                      decr20per_3p_rcklnd	,
                                      decr20per_3p_tc	,
                                      decr20per_amzn_sam	,
                                      decr20per_3p_sam	,
                                      decr20per_amzn_oly	,
                                      decr10per_3p_oly	,
                                      decr10per_3p_rcklnd	,
                                      decr10per_3p_sam	,
                                      decr10per_3p_tc	,
                                      decr10per_amzn_oly	,
                                      decr10per_amzn_sam	,
                                      decr5per_3p_oly	,
                                      decr5per_3p_rcklnd	,
                                      decr5per_3p_sam	,
                                      decr5per_3p_tc	,
                                      decr5per_amzn_oly	,
                                      decr5per_amzn_sam	,
                                      incr10per_3p_oly	,
                                      incr10per_3p_rcklnd	,
                                      incr10per_3p_sam	,
                                      incr10per_3p_tc	,
                                      incr10per_amzn_oly	,
                                      incr10per_amzn_sam	,
                                      incr5per_3p_oly	,
                                      incr5per_3p_rcklnd	,
                                      incr5per_3p_sam	,
                                      incr5per_3p_tc	,
                                      incr5per_amzn_oly	,
                                      incr5per_amzn_sam	,
                                      weekend,
                                      #additional covariates on reviews
                                      maxProduct_reviews_delsy_lag1,
                                      Product_reviews_kcole_lag1,
                                      Product_reviews_olympia_lag1,
                                      Product_reviews_rcklnd_lag1,
                                      Product_reviews_smsnite_lag1,
                                      Product_reviews_tc_lag1,
                                      meanprodstar_rate_delsy_lag1,
                                      prodstar_kcole_lag1,
                                      prodstar_olympia_lag1,
                                      prodstar_rcklnd_lag1,        
                                      prodstar_smsnite_lag1,
                                      prodstar_tc_lag1,
                                      #additional variables from RnR Round 2
                                      mean_starrateRL_3p_lag,
                                      mean_primeRL_3p_lag,
                                      seasonal_sale,
                                      ###broken down external site price changes with lags
                                      maxpricechange_sears,
                                      maxpricechange_searslag1,
                                      maxpricechange_searslag2,
                                      maxpricechange_searslag3,
                                      maxpricechange_wm,
                                      maxpricechange_wmlag1,
                                      maxpricechange_wmlag2,
                                      maxpricechange_wmlag3))

#FIXED AND INTERACTION EFFECTS JM RNR

gam9_clust2_rcklnd = gam(Y_clust2_rcklnd ~ 
                           Y_amzn_smsnite_lag1+
                           Y_clust1_smsnite_lag2+
                          # Answered_Questionsolympia_lag1+
                          # delsy_bottombrandlag1	+
                           buyboxprice_rcklnd_lag1 + 
                           #delsy_topbrandlag1	+
                           # oly_bottombrandlag1	+
                           # oly_topbrandlag1	+
                          # rcklnd_bottombrandlag1	+
                          # rcklnd_topbrandlag1	+
                           # smsnte_bottombrandlag1	+
                           # smsnte_topbrandlag1	+
                           #tc_bottombrandlag1	+
                           # tc_topbrandlag1	+
                           # incr20per_3p_oly	+
                          # incr20per_3p_rcklnd	+
                           #incr20per_3p_sam	+
                           #incr20per_3p_tc	+
                           #incr20per_amzn_oly	+
                           #incr20per_amzn_sam	+
                           decr20per_3p_oly	+
                           #decr20per_3p_rcklnd	+
                           #decr20per_3p_tc	+
                           #decr20per_amzn_sam	+
                           decr20per_3p_sam	+
                           #decr20per_amzn_oly	+
                           #  decr10per_3p_oly	+
                           # decr10per_3p_rcklnd	+
                           # decr10per_3p_sam	+
                          # decr10per_3p_tc	+
                           # decr10per_amzn_oly	+
                           # decr10per_amzn_sam	+
                           #decr5per_3p_oly	+
                           #decr5per_3p_rcklnd	+
                           # decr5per_3p_sam	+
                           #decr5per_3p_tc	+
                           decr5per_amzn_oly	+
                            #decr5per_amzn_sam	+
                           #incr10per_3p_oly	+
                           #incr10per_3p_rcklnd	+
                           #incr10per_3p_sam	+
                           #incr10per_3p_tc +
                           #meanpricechange_extsite_lag1+
                           #additional covariates on reviews
                           #maxProduct_reviews_delsy_lag1 +
                          Product_reviews_kcole_lag1 +
                           #Product_reviews_olympia_lag1 +
                           Product_reviews_rcklnd_lag1+
                           #Product_reviews_smsnite_lag1+
                           #Product_reviews_tc_lag1+
                           #meanprodstar_rate_delsy_lag1+
                           prodstar_kcole_lag1+
                         #  prodstar_olympia_lag1+
                           prodstar_rcklnd_lag1+        
                          # prodstar_smsnite_lag1+
                          # prodstar_tc_lag1+
                           weekend+
                          #incr10per_amzn_oly	+
                        # incr10per_amzn_sam	
                         # incr5per_3p_oly	+
                         #  incr5per_3p_rcklnd	+
                         # incr5per_3p_sam	+
                         # incr5per_3p_tc	
                         # incr5per_amzn_oly	+
                         #incr5per_amzn_sam	+
                         #+ as.factor(season)
                          #additional variables from RnR Round 2
                           seasonal_sale+
                          ###4th round additions
                          # maxpricechange_sears +
                        #  maxpricechange_searslag1 +
                         # maxpricechange_searslag2 +
                        #  maxpricechange_searslag3 +
                          #maxpricechange_wm  +
                          #maxpricechange_wmlag1 +
                        #  maxpricechange_wmlag2 +
                          maxpricechange_wmlag3
                         ,family= gaussian(link ='identity') ,data=data_clust2_rcklnd,method="REML",optimizer=c("outer","newton"), fit = TRUE)


summary(gam9_clust2_rcklnd)


#CLUSTER 2: TC


data_clust2_tc = data.frame(cbind(Y_clust2_tc_lag1,
                                  Y_clust2_tc_lag2,
                                  Y_clust2_tc_lag3,
                                  buyboxprice_tc_lag1,
                                  Y_amzn_smsnite_lag1,
                                  Y_clust1_smsnite_lag1,
                                  Y_amzn_olympia_lag1,
                                  Y_amzn_smsnite_lag2,
                                  Y_amzn_olympia_lag3,
                                  Y_clust2_olympia_lag3,
                                  meanseller_star_clust2_lag1,
                                  Y_clust1_smsnite_lag3,
                                  Y_amzn_olympia_lag2,
                                  meanperct_sellerate_clust2_lag1,
                                  Y_clust1_smsnite_lag2,
                                  num_prime_clust2_lag1,
                                  Y_clust2_rcklnd_lag2,
                                  num_Freeship_clust2_lag1,
                                  Answered_Questionsolympia_lag1,
                                  Y_clust2_olympia_lag1,
                                  delsy_bottombrandlag1	,
                                  delsy_topbrandlag1	,
                                  oly_bottombrandlag1	,
                                  oly_topbrandlag1	,
                                  rcklnd_bottombrandlag1	,
                                  rcklnd_topbrandlag1	,
                                  smsnte_bottombrandlag1	,
                                  smsnte_topbrandlag1	,
                                  tc_bottombrandlag1	,
                                  tc_topbrandlag1	,
                                  incr20per_3p_oly	,
                                  incr20per_3p_rcklnd	,
                                  incr20per_3p_sam	,
                                  incr20per_3p_tc	,
                                  incr20per_amzn_oly	,
                                  incr20per_amzn_sam	,
                                  decr20per_3p_oly	,
                                  decr20per_3p_rcklnd	,
                                  decr20per_3p_tc	,
                                  decr20per_amzn_sam	,
                                  decr20per_3p_sam	,
                                  decr20per_amzn_oly	,
                                  decr10per_3p_oly	,
                                  decr10per_3p_rcklnd	,
                                  decr10per_3p_sam	,
                                  decr10per_3p_tc	,
                                  decr10per_amzn_oly	,
                                  decr10per_amzn_sam	,
                                  decr5per_3p_oly	,
                                  decr5per_3p_rcklnd	,
                                  decr5per_3p_sam	,
                                  decr5per_3p_tc	,
                                  decr5per_amzn_oly	,
                                  decr5per_amzn_sam	,
                                  incr10per_3p_oly	,
                                  incr10per_3p_rcklnd	,
                                  incr10per_3p_sam	,
                                  incr10per_3p_tc	,
                                  incr10per_amzn_oly	,
                                  incr10per_amzn_sam	,
                                  incr5per_3p_oly	,
                                  incr5per_3p_rcklnd	,
                                  incr5per_3p_sam	,
                                  incr5per_3p_tc	,
                                  incr5per_amzn_oly	,
                                  incr5per_amzn_sam	,
                                  #additional covariates on reviews
                                  maxProduct_reviews_delsy_lag1,
                                  Product_reviews_kcole_lag1,
                                  Product_reviews_olympia_lag1,
                                  Product_reviews_rcklnd_lag1,
                                  Product_reviews_smsnite_lag1,
                                  Product_reviews_tc_lag1,
                                  meanprodstar_rate_delsy_lag1,
                                  prodstar_kcole_lag1,
                                  prodstar_olympia_lag1,
                                  prodstar_rcklnd_lag1,        
                                  prodstar_smsnite_lag1,
                                  prodstar_tc_lag1,
                                  weekend,
                                  #additional variables from RnR Round 2
                                  mean_starrateTC_3p_lag,
                                  mean_primeTC_3p_lag,
                                  seasonal_sale,
                                  ###broken down external site price changes with lags
                                  maxpricechange_sears,
                                  maxpricechange_searslag1,
                                  maxpricechange_searslag2,
                                  maxpricechange_searslag3,
                                  maxpricechange_wm,
                                  maxpricechange_wmlag1,
                                  maxpricechange_wmlag2,
                                  maxpricechange_wmlag3))

#fixed and interaction effects

gam5_clust2_tc = gam(Y_clust2_tc ~  
                     #  Y_amzn_smsnite_lag1+
                       Y_clust1_smsnite_lag3+
                       buyboxprice_tc_lag1 + 
                      # Y_clust2_tc_lag3	+
                       #Y_clust2_olympia_lag3+
                      # Y_clust2_rcklnd_lag2+
                       meanseller_star_clust2_lag1+
                       #meanpricechange_extsite_lag1 +
                    #   Answered_Questionsolympia_lag1+
                      # mean_starrateTC_3p_lag +
                      # mean_primeTC_3p_lag +
                      # delsy_topbrandlag1	+
                       # oly_bottombrandlag1	+
                       # oly_topbrandlag1	+
                       # rcklnd_bottombrandlag1	+
                      # rcklnd_topbrandlag1	+
                       # smsnte_bottombrandlag1	+
                       # smsnte_topbrandlag1	+
                     #  tc_bottombrandlag1	+
                      #  tc_topbrandlag1	+
                       # incr20per_3p_oly	+
                       #incr20per_3p_rcklnd	+
                      # incr20per_3p_sam	+
                       incr20per_3p_tc	+
                       #incr20per_amzn_oly	+
                       ##incr20per_amzn_sam	+
                       ##decr20per_3p_oly	+
                       #decr20per_3p_rcklnd	+
                       decr20per_3p_tc	+
                       ##decr20per_amzn_sam	+
                       ##decr20per_3p_sam	+
                      ## decr20per_amzn_oly	+
                       #  decr10per_3p_oly	+
                       # decr10per_3p_rcklnd	+
                       # decr10per_3p_sam	+
                       # decr10per_3p_tc	+
                       # decr10per_amzn_oly	+
                       # decr10per_amzn_sam	+
                       #decr5per_3p_oly	+
                       #decr5per_3p_rcklnd	+
                       # decr5per_3p_sam	+
                      # decr5per_3p_tc	+
                       #decr5per_amzn_oly	+
                      # decr5per_amzn_sam	+
                       #incr10per_3p_oly	+
                       #  incr10per_3p_rcklnd	+
                       ##incr10per_3p_sam	+
                       #incr10per_3p_tc +
                       #additional covariates on reviews
                       maxProduct_reviews_delsy_lag1 +
                      # Product_reviews_kcole_lag1 +
                       Product_reviews_olympia_lag1 +
                      # Product_reviews_rcklnd_lag1+
                     #  Product_reviews_smsnite_lag1+
                       meanprodstar_rate_delsy_lag1+
                      # prodstar_kcole_lag1+
                       prodstar_olympia_lag1+
                     #  prodstar_rcklnd_lag1+        
                      # prodstar_smsnite_lag1+
                       prodstar_tc_lag1+
                        weekend+
                       #mean_primeTC_clust1_lag1+
                       #mean_primeTC_clust2_lag1+
                       seasonal_sale +
                      # Product_reviews_tc_lag1
                       #weekend*Y_amzn_smsnite_lag1+
                      # weekend*Y_clust1_smsnite_lag3
                     #incr10per_amzn_oly	+
                     # incr10per_amzn_sam	
                     # incr5per_3p_oly	+
                     #  incr5per_3p_rcklnd	+
                     # incr5per_3p_sam	+
                     # incr5per_3p_tc	
                     # incr5per_amzn_oly	+
                     #incr5per_amzn_sam	+
                     #+ as.factor(season)+
                     ###4th round additions
                     # maxpricechange_sears +
                     # maxpricechange_searslag1 +
                     # maxpricechange_searslag2 +
                     # maxpricechange_searslag3 +
                      maxpricechange_wm  
                     # maxpricechange_wmlag1 +
                     # maxpricechange_wmlag2 +
                     # maxpricechange_wmlag3
                     ,family= gaussian(link ='identity') ,data=data_clust2_tc,method="REML",optimizer=c("outer","newton"), fit = TRUE)



summary(gam5_clust2_tc)


linear_clust2 = lm(Y_clust2_tc ~  
                       #  Y_amzn_smsnite_lag1+
                       Y_clust1_smsnite_lag3+
                       buyboxprice_tc_lag1 + 
                       # Y_clust2_tc_lag3	+
                       #Y_clust2_olympia_lag3+
                       # Y_clust2_rcklnd_lag2+
                       meanseller_star_clust2_lag1+
                       #meanpricechange_extsite_lag1 +
                       #   Answered_Questionsolympia_lag1+
                       mean_starrateTC_3p_lag +
                       # mean_primeTC_3p_lag +
                       # delsy_topbrandlag1	+
                       # oly_bottombrandlag1	+
                       # oly_topbrandlag1	+
                       # rcklnd_bottombrandlag1	+
                       # rcklnd_topbrandlag1	+
                       # smsnte_bottombrandlag1	+
                       # smsnte_topbrandlag1	+
                       #  tc_bottombrandlag1	+
                       #  tc_topbrandlag1	+
                       # incr20per_3p_oly	+
                       #incr20per_3p_rcklnd	+
                       # incr20per_3p_sam	+
                       incr20per_3p_tc	+
                       #incr20per_amzn_oly	+
                       ##incr20per_amzn_sam	+
                       ##decr20per_3p_oly	+
                       #decr20per_3p_rcklnd	+
                       decr20per_3p_tc	+
                       ##decr20per_amzn_sam	+
                       ##decr20per_3p_sam	+
                       ## decr20per_amzn_oly	+
                       #  decr10per_3p_oly	+
                       # decr10per_3p_rcklnd	+
                       # decr10per_3p_sam	+
                       # decr10per_3p_tc	+
                       # decr10per_amzn_oly	+
                       # decr10per_amzn_sam	+
                       #decr5per_3p_oly	+
                       #decr5per_3p_rcklnd	+
                       # decr5per_3p_sam	+
                       # decr5per_3p_tc	+
                       #decr5per_amzn_oly	+
                       # decr5per_amzn_sam	+
                       #incr10per_3p_oly	+
                       #  incr10per_3p_rcklnd	+
                       ##incr10per_3p_sam	+
                       #incr10per_3p_tc +
                       #additional covariates on reviews
                       maxProduct_reviews_delsy_lag1 +
                       # Product_reviews_kcole_lag1 +
                       Product_reviews_olympia_lag1 +
                       # Product_reviews_rcklnd_lag1+
                       #  Product_reviews_smsnite_lag1+
                       meanprodstar_rate_delsy_lag1+
                       # prodstar_kcole_lag1+
                       prodstar_olympia_lag1+
                       #  prodstar_rcklnd_lag1+        
                       # prodstar_smsnite_lag1+
                       prodstar_tc_lag1+
                       weekend+
                       #mean_primeTC_clust1_lag1+
                       #mean_primeTC_clust2_lag1+
                       seasonal_sale +
                       # Product_reviews_tc_lag1
                       #weekend*Y_amzn_smsnite_lag1+
                       # weekend*Y_clust1_smsnite_lag3
                       #incr10per_amzn_oly	+
                       # incr10per_amzn_sam	
                       # incr5per_3p_oly	+
                       #  incr5per_3p_rcklnd	+
                       # incr5per_3p_sam	+
                       # incr5per_3p_tc	
                       # incr5per_amzn_oly	+
                       #incr5per_amzn_sam	+
                       #+ as.factor(season)+
                       ###4th round additions
                       # maxpricechange_sears +
                       # maxpricechange_searslag1 +
                       # maxpricechange_searslag2 +
                       # maxpricechange_searslag3 +
                       maxpricechange_wm  
                     # maxpricechange_wmlag1 +
                     # maxpricechange_wmlag2 +
                     # maxpricechange_wmlag3
                     ,data=data_clust2_tc)



summary(gam5_clust2_tc)

summary(linear_clust2)



